#ifndef POSITIONINTERPOLATOR_H
#define POSITIONINTERPOLATOR_H

#include "bga/system/TimerListener.h"

#include "bga/math/Point3.h"

#include "bga/graphics/SceneNode.h"

/**
 * \namespace bga
 * \brief API namespace
 */
namespace bga
{

/*!
 * \class PositionInterpolator
 * \brief Defines an animation of the camera between two positions
 *
 *
 */
class BOARD_HELL_ENGINE PositionInterpolator : public TimerListener
{
	public:

        /**
         * Constructor
         * \param animationTime : Time of the animation
         * \param node : node we animate
         */
		PositionInterpolator(float animationTime, SceneNode* node = NULL);

		/**
		 * Destructor
		 */
		virtual ~PositionInterpolator();

        void setNode(SceneNode* node);

        /**
         * \brief Start the animation of the node until the final position
         * \param initial : initial position of the node
         * \param final : final position of the node
         */
		void startAnimation(const Point3f& initial, const Point3f& final);

        /**
         * \brief To know if the node is currently animated
         * \return true if the node is animated false else
         */
		bool isRunning() const;

		/*!
         * \brief Function to handle a time elapsed
         * \param event : TimerEvent containing all the information about the sent event
         *
         * Function to handle a time elapsed. This function is abstract.
         */
        virtual void timeElapsed(const bga::TimerEvent &event);
	protected:

	protected:
        float animationTime;  ///!< Time of the animation

        SceneNode* node;       ///!< Node we are moving

        Point3f initial;   ///!< Initial quaternion. Initial direction of the camera
        Point3f final;     ///!< Final direction of the camera

        Point3f previousPoint;  ///!< Tempory point to determine Vector translation

        Timer timer;          ///!< Timer used for the animation

        float currentT;       ///!< Current value of the interpolation. 0 <= currentT <= 1
        Vector3f unaryVector;  ///!< Unary vector
        unsigned int k;         ///!< Step for interpolation

};


}

#endif // POSITIONINTERPOLATOR_H


